﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Project.MVC.Model;
using Project.MVC.Service;
namespace Project.MVC.Web.Controllers
{
    public class SanPhamController : Controller
    {
       #region Services
        private readonly IProductServices service;

        public SanPhamController()
            : this(new ProductServices()
            )
        {
        }

        public SanPhamController(IProductServices iService

            )
        {
            service = iService;

        }
        #endregion

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult ProductHome()
        {
            var viewModel = service.GetList2Grid().OrderByDescending(c => c.Id).Take(6);
            return PartialView("ProductHome", viewModel);
            
        }
        public ActionResult Detail(int id)
        {
            var viewModel = service.GetByKey(id);
            return View("Detail",viewModel);
        }
    }
}
